package ${package};

import little.ant.platform.annotation.Controller;
import little.ant.platform.controller.BaseController;
import ${basePackage}.service.${className}Service;
import ${basePackage}.validator.${className}Validator;
import ${basePackage}.model.${className};

import org.apache.log4j.Logger;

import com.jfinal.aop.Before;

/**
 * XXX 管理	
 * 描述：
 * 
 * /jf/${basePath}/${classNameSmall}
 * /jf/${basePath}/${classNameSmall}/save
 * /jf/${basePath}/${classNameSmall}/edit
 * /jf/${basePath}/${classNameSmall}/update
 * /jf/${basePath}/${classNameSmall}/view
 * /jf/${basePath}/${classNameSmall}/delete
 * /common/${classNameSmall}/add.html
 * 
 */
@Controller(controllerKey = "/jf/${basePath}/${classNameSmall}")
public class ${className}Controller extends BaseController {

	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(${className}Controller.class);
	
	/**
	 * 列表
	 */
	public void index() {
		paging(ConstantInit.db_dataSource_main, splitPage, BaseModel.sqlId_splitPage_select, ${className}.sqlId_splitPage_from);
		render("/${basePath}/${classNameSmall}/list.html");
	}
	
	/**
	 * 保存
	 */
	@Before(${className}Validator.class)
	public void save() {
		getModel(${className}.class).save();
		render("/${basePath}/${classNameSmall}/add.html");
	}
	
	/**
	 * 准备更新
	 */
	public void edit() {
		${className} ${classNameSmall} = ${className}.dao.findById(getPara());
		setAttr("${classNameSmall}", ${classNameSmall});
		render("/${basePath}/${classNameSmall}/update.html");
	}
	
	/**
	 * 更新
	 */
	@Before(${className}Validator.class)
	public void update() {
		getModel(${className}.class).update();
		redirect("/jf/${basePath}/${classNameSmall}");
	}

	/**
	 * 查看
	 */
	public void view() {
		${className} ${classNameSmall} = ${className}.dao.findById(getPara());
		setAttr("${classNameSmall}", ${classNameSmall});
		render("/${basePath}/${classNameSmall}/view.html");
	}
	
	/**
	 * 删除
	 */
	public void delete() {
		${className}Service.service.delete("${tableName}", getPara() == null ? ids : getPara());
		redirect("/jf/${basePath}/${classNameSmall}");
	}
	
}


